package com.test.socket.demo1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class Handle implements Runnable {
	
	private Socket socket;

	public Handle(Socket socket) {
		super();
		this.socket = socket;
	}

	@Override
	public void run() {
		PrintWriter pw = null;
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));
			String str = "";
			while ((str = br.readLine()) != null) {
				System.out.println(str);
			}
			pw = new PrintWriter(socket.getOutputStream());
			pw.println("服务器端接受成功！");
			pw.flush();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			pw.close();
		}
	}

	
}
